/**
 * Copyright (C), 2020-2020, 人生无限公司
 * FileName: Test2
 * Description:
 *
 * @create: 2020/7/17 14:37
 * @author Reanon
 * @version JDK 1.8.0_251
 */
package cn.reanon.day06.homework.test2;

import java.util.ArrayList;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Student> list = new ArrayList<>();
        while (true) {
            System.out.println("1.录入信息 0.退出");
            int i = scanner.nextInt();
            switch (i) {
                case 1:
                    inputStu(list, scanner);
                    break;
                case 0:
                    System.out.println("录入完毕");
            }
            if (i == 0) {
                break;
            }
        }

        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            student.show();
        }
    }

    private static void inputStu(ArrayList<Student> list, Scanner sc) {
        System.out.println("请输入姓名:");
        String name = sc.next();
        System.out.println("请输入年龄:");
        int age = sc.nextInt();
        Student student = new Student(age, name);
        list.add(student);
    }

}
